﻿using MetroDataApi.Models;
using Newtonsoft.Json;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Web.Http;

namespace MetroDataApi.Controllers
{
    public class GetProjectSummaryController : ApiController
    {

        // GET api/getprojectsummary/5
        public string Get(int prjId)
        {
            using (var db = new MetroDataDataContext())
            {
                var summary = db.MonitorProjectExtraInfo.SingleOrDefault(p => p.PrjId == prjId);
                var summaryList = summary == null || summary.PrjSummary == null ? new string[] { } :
                    Regex.Split(summary.PrjSummary, "\r\n");
                return JsonConvert.SerializeObject(summaryList);
            }
        }

    }
}
